﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using ChampionsLeagueBets.Domain.Common;
using SharpArch.Domain.DomainModel;

namespace ChampionsLeagueBets.Domain
{
	[DisplayName("Użytkownik")]
    public class User : BaseEntity
    {
        [Required(ErrorMessage = "Musisz podać nazwę użytkownika")]
		[DisplayName("Nazwa użytkownika")]
		[StringLength(50)]
		[RegularExpression(RegularExpression.Login, ErrorMessage = "Login zawiera niedopuszczalne znaki")]
		[Remote("UserNameAvailable", "Users", AdditionalFields = "Id")]
        public virtual string UserName { get; set; }
        
		[Required(ErrorMessage = "Musisz podać imię")]
		[DisplayName("Imię")]
		public virtual string FirstName { get; set; }
        
		[Required(ErrorMessage = "Musisz podać nazwisko")]
		[DisplayName("Nazwisko")]
        public virtual string Surname { get; set; }

		[DisplayName("Hasło")]
        public virtual string Password { get; set; }

		[DisplayName("Email")]
		[RegularExpression(RegularExpression.Email, ErrorMessage = "Niepoprawny format adresu email")]
		[Required(ErrorMessage = "Musisz podać adres email")]
        public virtual string Email { get; set; }

		[DisplayName("Zakłady")]
		public virtual IList<TournamentUserResult> TournamentUserResults { get; set; }

		[DisplayName("Administrator")]
		public virtual bool IsAdmin { get; set; }

		[DisplayName("Zaproszenia")]
		public virtual IList<Invitation> Invitations { get; set; }

		[DisplayName("Guid przywracania hasła")]
		public virtual Guid? PasswordRecoveryGuid { get; set; }

		[DisplayName("Zaproszenie")]
		public virtual InvitedPerson InvitedPerson { get; set; }

		[DisplayName("Imię i nazwisko")]
    	public virtual string FullName
    	{
    		get { return string.Format("{0} {1}", FirstName, Surname); }
    	}
    }
}